﻿using DtoFw;
using DtoFw.Query;
using DtoFw.Result;
using Microsoft.AspNetCore.Mvc;
using Service;

namespace SceneEvidenceAPI.Controllers
{
    /// <summary>
    /// 用户
    /// </summary>
    [Route("api/role")]
    public class MainRoleController : BaseController
    {
        private readonly MainRoleService rep_role;
        public MainRoleController(MainRoleService role) 
        {
            rep_role = role;
        }
        /// <summary>
        /// 角色分页查询
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>
        [HttpGet("get/pager")]
        public BaseGenericResult<Pager<RoleResult>> Query([FromQuery] BaseQuery query)
        {
            return rep_role.Query(query);
        }
        /// <summary>
        /// 移除角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete("delete")]
        public BaseResult DeleteRoles([FromBody]DeleteDto query)
        {
            return rep_role.Delete(query);
        }
        /// <summary>
        /// 获取权限分配菜单
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet("get/role/menus")]
        public BaseGenericResult<RoleMapMenuResult> GetRoleMapMenus([FromQuery] RoleQuery query)
        {
            return rep_role.GetRoleMapMenus(query);
        }
        /// <summary>
        /// 保存角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("post/role")]
        public BaseResult AddRole([FromBody] RoleEditInfo request)
        {
            return rep_role.AddRole(request);
        }
        /// <summary>
        /// 获取指定角色对象
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet("get/{roleId}")]
        public BaseGenericResult<RoleResult> QueryRole(long roleId)
        {
            return rep_role.QueryRole(roleId);
        }
    }
}
